package com.cedifie.lendapp.ui.loan.adapter

import android.graphics.Color
import androidx.recyclerview.widget.RecyclerView
import com.cedifie.lendapp.R
import com.cedifie.lib_baseadapter.CEDRecyclerViewAdapter
import com.cedifie.lib_baseadapter.CEDViewHolderHelper
import org.json.JSONObject

/**
 * Cedifie
 * @Author wwdeng
 * @CreateTime: 2024/4/24 14:42
 * @Annotation：贷款申请 老客选择时间 适配器
 */
class CedLoanApplyDaysAdapter(recyclerView: RecyclerView?) : CEDRecyclerViewAdapter<JSONObject>(recyclerView, R.layout.item_loan_apply_days) {
    override fun setItemChildListener(helper: CEDViewHolderHelper, viewType: Int) {
        helper.setItemChildClickListener(R.id.textDays) //点击Item
    }

    override fun fillData(helper: CEDViewHolderHelper, position: Int, model: JSONObject) {
        val textDays = helper.getTextView(R.id.textDays)
        textDays.text = String.format(mContext.getString(R.string.loan_apply_loan_term_days),model.optString("day"))

        if (model.optBoolean("isSelect",false)){
            textDays.setBackgroundResource(R.drawable.btn_background)
            textDays.setTextColor(Color.parseColor("#FFFFFFFF"))
        } else {
            textDays.setBackgroundResource(R.drawable.ced_circle_fill_fff0f0f0)
            textDays.setTextColor(Color.parseColor("#FF6C6C6C"))
        }
    }
}